var app =getApp()
Page({
  data: {
    //设置初始值
    array: ['2018', '2019','2020'],
    objectArray: [
      {
        id: 0,
        name: '2018'
      },
      {
        id: 1,
        name: '2019'
      },
      {
        id: 2,
        name: '2020'
      }

    ],
    array1: ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'],
    objectArray: [
      {
        id: 0,
        name: '01'
      },
      {
        id: 1,
        name: '02'
      },
      {
        id: 2,
        name: '03'
      },
      {
        id: 3,
        name: '04'
      },
      {
        id: 4,
        name: '05'
      },
      {
        id: 5,
        name: '06'
      },
      {
        id: 6,
        name: '07'
      },
      {
        id: 7,
        name: '08'
      },
      {
        id: 8,
        name: '09'
      },
      {
        id: 9,
        name: '10'
      },
      {
        id: 10,
        name: '11'
      },
      {
        id: 11,
        name: '12'
      }
    ],

    array2:['2018', '2019', '2020'],
    objectArray: [
      {
        id: 0,
        name: '2018'
      },
      {
        id: 1,
        name: '2019'
      },
      {
        id: 2,
        name: '2020'
      }

    ],
    array3: ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'],
    objectArray: [
      {
        id: 0,
        name: '01'
      },
      {
        id: 1,
        name: '02'
      },
      {
        id: 2,
        name: '03'
      },
      {
        id: 3,
        name: '04'
      },
      {
        id: 4,
        name: '05'
      },
      {
        id: 5,
        name: '06'
      },
      {
        id: 6,
        name: '07'
      },
      {
        id: 7,
        name: '08'
      },
      {
        id: 8,
        name: '09'
      },
      {
        id: 9,
        name: '10'
      },
      {
        id: 10,
        name: '11'
      },
      {
        id: 11,
        name: '12'
      }
    ],
  },
  //跳转报表界面
  gotoPage: function (e) {
    if (app.globalData.year1 + app.globalData.month1 > app.globalData.year2 + app.globalData.month2){
      wx.showModal({
        title: '提示',
        content: '结束时间需要晚于开始时间',
      })
    }
    else  {
    var page = e.currentTarget.dataset.page;
    wx.navigateTo({
      url: '../../program/' + page + '/' + page
    });
    }
  },
  bindPickerChange: function (e) {
   // console.log('picker发送选择改变，携带值为', e.detail.value);
    app.globalData.year1=this.data.array[e.detail.value];
    //console.log(app.globalData.year1);
    this.setData({
      index: e.detail.value,
    })
  },
  bindPickerChange1: function (e) {
   // console.log('picker发送选择改变，携带值为', e.detail.value)
    app.globalData.month1 = this.data.array1[e.detail.value];
    this.setData({
      index1: e.detail.value
    })
  },
  bindPickerChange2: function (e) {
    // console.log('picker发送选择改变，携带值为', e.detail.value);
    app.globalData.year2 = this.data.array2[e.detail.value];
    //console.log(app.globalData.year1);
    this.setData({
      index2: e.detail.value,
    })
  },
  bindPickerChange3: function (e) {
    // console.log('picker发送选择改变，携带值为', e.detail.value)
    app.globalData.month2 = this.data.array3[e.detail.value];
    this.setData({
      index3: e.detail.value
    })
  },
  //选择时间事件
  bindDateChange1: function (e) {
    console.log(e.detail.value)
    this.setData({
      dates1: e.detail.value
    })
  },
  bindDateChange2: function (e) {
    console.log(e.detail.value)
    this.setData({
      dates2: e.detail.value
    })
  },
})